#include "SehnsuchtPrecompiled.hxx"
#include "SehnsuchtTimer.hxx"

Sehnsucht::BasicTimer::BasicTimer() : 
	m_UpdateCallback(&Sehnsucht::BasicTimer::UpdateNonfixedStepImpl),
	BasicTimerView()
{
	QueryPerformanceFrequency(_Outptr_opt_ _To_large_int_ptr &m_TicksPerSecond64);
	QueryPerformanceCounter(_Outptr_opt_ _To_large_int_ptr &m_CurrentTicks64);
	m_OneSecondTicks64 = m_CurrentTicks64;
	m_StartupTicks64 = m_CurrentTicks64;
}

void Sehnsucht::BasicTimer::SetFixedTimeStep(Float32Const fStep)
{
	if (fStep > 0.0F)
	{
		m_bUseFixedDelta = false; m_fFixedDelta = 0.0f;
		m_UpdateCallback = &Sehnsucht::BasicTimer::UpdateNonfixedStepImpl;
	}
	else
	{
		m_bUseFixedDelta = true; m_fFixedDelta = fStep;
		m_UpdateCallback = &Sehnsucht::BasicTimer::UpdateFixedStepImpl;
	}
}

void Sehnsucht::BasicTimer::Reset()
{
	m_iFramesPerSecond = 0;
	m_iFrameCount = 0;
	m_fDelta = 0.0f;
}